import 'package:flutter/material.dart';

// 由于ChangeNotifier是mixin，所以这是用with
class CartProvider with ChangeNotifier {
  List _list = [];

  List get list => _list;
  int get cartNum => _list.length;

  // 添加数组
  addItem(item) {
    _list.add(item);
    notifyListeners();
  }

  //删除
  removeItem(item) {
    _list.remove(item);
    notifyListeners();
  }
}
